<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绘制心形</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        /*让容器的宽度和高度都充满全屏*/ 
        html,body{
            width: 100%;
            height: 100%;
        }

        body{
            background-color: #ffc0cb;
            display: flex;
            flex-direction: row;
            align-items: center;/*垂直居中*/
            justify-content: center;/*水平居中*/
        }
            
       .heart{
            width: 200px;
            height: 200px;
            background: red; 
            position: relative;
            transform: rotate(45deg);/*旋转45*/  
            animation: heartbit 2s alternate infinite;
                                          
        }

        /*伪元素*/  
        .heart:before{
            content: "";
            width: 200px;
            height: 100px;
            position: absolute;
            top: -99px;
            left: 0;
            background: red;
            border-radius: 100px 100px 0 0; 
            
        }

        .heart::after{
            content: "";
            width: 100px;
            height: 200px;
            position: absolute;
            top: 0;
            left: -99px;
            background:red;
            border-radius:100px 0 0   100px;
              
        }
        /*通过动画效果让心跳动起来*/ 
        @keyframes heartbit{
            0%{
                transform: rotate(45deg) scale(0.6) ;
            }
            100%{
                transform: rotate(45deg) scale(1.2)
            }

        }

        @keyframes item{
            0%{
                transform: rotate(0) scale(0.6) ;
            }
            100%{
                transform: rotate(45deg) scale(1.2)
            }

        }
        .item {
            width: 200px;
            height: 200px;
            position: absolute;
            color: white;
            text-align: center;
            line-height: 100px;
            animation: item 2s alternate infinite;
        }

        
            
       </style>

</head>
<body>
    <div class="heart"></div>
    <div class="item" style="color: white;">爱你</div>
</body>
</html>